home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / vm / vmBoot.c < prev    next >
C/C++ Source or Header  |  1991-03-11  |  3KB  |  106 lines

  1. /* vmBoot.c -
  2.  *
  3.  *    This file contains routines that allocate memory for tables at boot 
  4.  *    time.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifndef lint
  11. static char rcsid[] = "$Header: /sprite/src/kernel/vm/RCS/vmBoot.c,v 9.3 91/03/11 11:45:14 kupfer Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14. #include <sprite.h>
  15. #include <sys.h>
  16. #include <vm.h>
  17. #include <vmInt.h>
  18. #include <bstring.h>
  19.  
  20. Address    vmMemEnd;
  21. Boolean    vmNoBootAlloc = TRUE;
  22.  
  23.  
  24. /*
  25.  * ----------------------------------------------------------------------------
  26.  *
  27.  * Vm_BootInit --
  28.  *
  29.  *    Initialize virtual memory and the variable that determines 
  30.  *    where to start allocating memory at boot time.
  31.  *
  32.  * Results:
  33.  *    None.
  34.  *
  35.  * Side effects:
  36.  *         vmMemEnd is set and several variables are set by the machine dependent
  37.  *    boot routine.
  38.  *
  39.  * ----------------------------------------------------------------------------
  40.  */
  41. void
  42. Vm_BootInit()
  43. {
  44.     extern unsigned int end;
  45.  
  46.     /* 
  47.      * Don't bother initializing vmStat.minFSPages.  During booting it
  48.      * will get set to 0 or 1, which isn't interesting.  So we will
  49.      * put something in the bootcmds script to set minFSPages to the
  50.      * current cache size after the system has finished booting.
  51.      */
  52.     bzero((Address) &vmStat, sizeof(vmStat));
  53.  
  54.     vmNoBootAlloc = FALSE;
  55.     vmMemEnd = (Address) &end;
  56.     /*
  57.      * Make sure that we start on a four byte boundary.
  58.      */
  59. #ifdef sun4        /* temporary test - this will not last */
  60.     vmMemEnd = (Address) (((int) vmMemEnd + 7) & ~7);    /* double-word bound. */
  61. #else
  62.     vmMemEnd = (Address) (((int) vmMemEnd + 3) & ~3);
  63. #endif /* sun4 */
  64.  
  65.     VmMach_BootInit(&vm_PageSize, &vmPageShift, &vmPageTableInc,
  66.             &vmKernMemSize, &vmStat.numPhysPages, &vmMaxMachSegs,
  67.             &vmMaxProcesses);
  68. }
  69.  
  70.  
  71. /*
  72.  * ----------------------------------------------------------------------------
  73.  *
  74.  * Vm_BootAlloc --
  75.  *
  76.  *     Allocate a block of memory of the given size starting at the
  77.  *     current end of kernel memory.
  78.  *
  79.  * Results:
  80.  *     A pointer to the allocated memory.
  81.  *
  82.  * Side effects:
  83.  *     vmMemEnd is incremented.
  84.  *
  85.  * ----------------------------------------------------------------------------
  86.  */
  87. Address
  88. Vm_BootAlloc(numBytes)
  89. int numBytes;
  90. {
  91.     Address    addr;
  92.  
  93.     if (vmNoBootAlloc) {
  94.     panic("Trying to use Vm_BootAlloc either before calling Vm_BootAllocInit\r\nor after calling Vm_Init\r\n");
  95.     addr = 0;
  96.     return(addr);
  97.     }
  98.     addr =  vmMemEnd;
  99. #ifdef sun4    /* temporary test - this will not last */
  100.     vmMemEnd += (numBytes + 7) & ~7;    /* double-word boundary */
  101. #else
  102.     vmMemEnd += (numBytes + 3) & ~3;
  103. #endif /* sun4 */
  104.     return(addr);
  105. }
  106.